import React from 'react';
import PropTypes from 'prop-types';
import { Form, Select } from 'antd';

const { Item } = Form;
const { Option } = Select;

// HR确认申请
const Ceo = ({ form, type, detail, processState }) => {
    const { getFieldDecorator } = form;
    const { approval } = detail;
    const approvalMsg = approval === '0' ? '同意' : '拒绝';
    return (
        <div>
            <Item required={type === 'edit' && processState !== 'success'} label="区域CEO给予调岗结果">
                {(type === 'edit' && processState !== 'success') ? getFieldDecorator('approval', {
                    rules: [
                        {
                            required: true,
                            message: '请选择调岗结果！'
                        }
                    ]
                })(
                    <Select>
                        <Option value="0">同意</Option>
                        <Option value="1">拒绝</Option>
                    </Select>
                ) : approvalMsg}
                {type === 'detail' && getFieldDecorator('approval', {
                    initialValue: detail.approval
                })(
                    <Select style={{ display: 'none' }}>
                        <Option value="0">同意</Option>
                        <Option value="1">拒绝</Option>
                    </Select>
                )}
            </Item>
        </div>
    )
};

Ceo.propTypes = {
    type: PropTypes.oneOf(['edit', 'detail']).isRequired
};

export default Ceo;
